<template>
	<view>
		<u-navbar :is-back="true" title="到院就诊" title-color="white" :background="background"></u-navbar>
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs-swiper activeColor="#44a3ff" ref="tabs" :list="list" :current="current" @change="change"
					:is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition"
				@animationfinish="animationfinish">
				<swiper-item class="swiper-item">
					<view class="u-padding-26 u-m-t-26 u-m-b-26 bg" v-for="(item,index) in orderList" :key="index"
						@click="openinfo('/pages/order/lineOff/seeShow/seeShow?id='+item.id)">
						<view class="">
							<image :src="oss+item.userinfo.avatar" mode=""
								style="width: 50rpx;height: 50rpx;border-radius: 50%;margin-right: 20rpx;"></image>
							<text style="position: relative;top:-20rpx">{{item.userinfo.nickname}}</text>
						</view>
						<view class="u-flex u-margin-top-10 u-margin-bottom-10">
							<view class="u-flex-1">
								<image :src="oss+item.items[0].image_id" mode=""
									style="width: 150rpx;border-radius: 10rpx;height: 150rpx;"></image>
							</view>
							<view class="u-flex-3">
								<p class="u-col-top">{{item.items[0].name}}</p>
								<br>
								<p>￥{{item.items[0].price}}</p>
							</view>
						</view>
						<view class="" style="width: 100%;">
							<p style="color: #6c6c6c;display: inline-block;" class="u-font-10">
								<u-icon name="map" class="u-m-r-10"></u-icon>{{item.hospital.title}}
							</p>
							<p style="color: #6c6c6c;display: inline-block;float: right;margin-top: 5rpx;"
								class="u-font-10">
								<u-icon name="clock" class="u-m-r-10"></u-icon>
								{{$u.timeFormat(item.reservetime, 'yyyy.mm.dd hh:MM')}}
							</p>
						</view>
					</view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<view class="u-padding-26 u-m-t-26 u-m-b-26 bg" v-for="(item,index) in orderList" :key="index"
						@click="openinfo('/pages/order/lineOff/seeShow/seeShow')">
						<view class="">
							<image :src="item.userinfo.avatar" mode=""
								style="width: 50rpx;height: 50rpx;border-radius: 50%;margin-right: 20rpx;"></image>
							<text style="position: relative;top:-20rpx">{{item.userinfo.nickname}}</text>
						</view>
						<view class="u-flex u-margin-top-10 u-margin-bottom-10">
							<view class="u-flex-1">
								<image src="../../../static/goods/p1.jpg" mode=""
									style="width: 150rpx;border-radius: 10rpx;height: 150rpx;"></image>
							</view>
							<view class="u-flex-3">
								<p class="u-col-top">{{item.items[0].name}}</p>
								<br>
								<p>￥{{item.items[0].price}}</p>
							</view>
						</view>
						<view class="" style="width: 100%;">
							<p style="color: #6c6c6c;display: inline-block;" class="u-font-10">
								<u-icon name="map" class="u-m-r-10"></u-icon>{{item.hospital.title}}
							</p>
							<p style="color: #6c6c6c;display: inline-block;float: right;margin-top: 5rpx;"
								class="u-font-10">
								<u-icon name="clock" class="u-m-r-10"></u-icon>
								{{$u.timeFormat(item.reservetime, 'yyyy.mm.dd hh:MM')}}
							</p>
						</view>
					</view>
				</swiper-item>
				<swiper-item class="swiper-item">
					<view class="u-padding-26 u-m-t-26 u-m-b-26 bg" v-for="(item,index) in orderList" :key="index"
						@click="openinfo('/pages/order/lineOff/seeShow/seeShow')">
						<view class="">
							<image :src="item.userinfo.avatar" mode=""
								style="width: 50rpx;height: 50rpx;border-radius: 50%;margin-right: 20rpx;"></image>
							<text style="position: relative;top:-20rpx">{{item.userinfo.nickname}}</text>
						</view>
						<view class="u-flex u-margin-top-10 u-margin-bottom-10">
							<view class="u-flex-1">
								<image src="../../../static/goods/p1.jpg" mode=""
									style="width: 150rpx;border-radius: 10rpx;height: 150rpx;"></image>
							</view>
							<view class="u-flex-3">
								<p class="u-col-top">{{item.items[0].name}}</p>
								<br>
								<p>￥{{item.items[0].price}}</p>
							</view>
						</view>
						<view class="" style="width: 100%;">
							<p style="color: #6c6c6c;display: inline-block;" class="u-font-10">
								<u-icon name="map" class="u-m-r-10"></u-icon>{{item.hospital.title}}
							</p>
							<p style="color: #6c6c6c;display: inline-block;float: right;margin-top: 5rpx;"
								class="u-font-10">
								<u-icon name="clock" class="u-m-r-10"></u-icon>
								{{$u.timeFormat(item.reservetime, 'yyyy.mm.dd hh:MM')}}
							</p>
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#00a8ff'
				},
				oss: 'http://zjmeifeng.oss-cn-beijing.aliyuncs.com/',
				orderList: '',
				list: [{
						name: '待就诊'
					},
					{
						name: '进行中'
					},
					{
						name: '已完成',
					}
				],
				current: 0,
				swiperCurrent: 0,
				tabsHeight: 0,
				dx: 0,
				loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
			};
		},
		onShow() {
			this.getOrderList(0);
		},



		computed: {},
		methods: {
			openinfo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 获取到院就诊订单
			getOrderList(index) {
				this.$apiToHos.orderlist({
					page: '',
					limit: '',
					show_status: index
				}).then((res) => {
					console.log('request success', res);
					
					this.orderList=res.data.data.items;
					console.log("orderList:"+res.data.data.items)
					
				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			// tab栏切换
			change(index) {
				console.log(index);
				this.getOrderList(index);
				this.swiperCurrent = index;
			},
			transition({
				detail: {
					dx
				}
			}) {
				this.$refs.tabs.setDx(dx);
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.$refs.tabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			}
		}
	};
</script>

<style>
	/* #ifndef H5 */
	page {
		height: 100%;
		background-color: #f2f2f2;
	}
	/* #endif */
</style>

<style lang="scss" scoped>
	.bg {
		background-color: #FFFFFF;
	}

	.order {
		width: 710rpx;
		background-color: #ffffff;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;

		.top {
			display: flex;
			justify-content: space-between;

			.left {
				display: flex;
				align-items: center;

				.store {
					margin: 0 10rpx;
					font-size: 32rpx;
					font-weight: bold;
				}
			}

			.right {
				color: $u-type-warning-dark;
			}
		}

		.item {
			display: flex;
			margin: 20rpx 0 0;

			.left {
				margin-right: 20rpx;

				image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}
			}

			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}

				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}

				.delivery-time {
					color: #e5d001;
					font-size: 24rpx;
				}
			}

			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;

				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}

				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}

		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;

			.total-price {
				font-size: 32rpx;
			}
		}

		.bottom {
			display: flex;
			margin-top: 40rpx;
			padding: 0 10rpx;
			justify-content: space-between;
			align-items: center;

			.btn {
				line-height: 52rpx;
				width: 160rpx;
				border-radius: 26rpx;
				border: 2rpx solid $u-border-color;
				font-size: 26rpx;
				text-align: center;
				color: $u-type-info-dark;
			}

			.evaluate {
				color: $u-type-warning-dark;
				border-color: $u-type-warning-dark;
			}
		}
	}

	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;

		image {
			width: 164rpx;
			height: 164rpx;
			border-radius: 50%;
			margin-bottom: 20rpx;
		}

		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}

		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
		}
	}

	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}

	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}
</style>
